<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateArticlesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('articles', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('category_id');//类别
            $table->integer('user_id')->unsigned();//用户id
            $table->string('title',100);//标题
            $table->longText('content');//内容
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('admin_users');

        });
        Schema::create('articles_comment', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('article_id');//id
            $table->integer('from_uid');//用户id
            $table->longText('content');//内容
            $table->timestamps();
        });
        Schema::create('articles_comment_tree', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('parent_id');//评论父id
            $table->integer('child_id');//子id
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('articles');
    }
}
